<?php
     include_once "src/controller/blmanagement/ReservationManagement.php";

$Reservation = new Reservation();

$StartDate = '2010-05-03';
$EndDate = '2010-05-09';
$UserID = 19;
$ResourceID = 1;

echo "Add a new Record Without the ReOccurrence_id and Stop_Date set<br/>";

$Reservation->setResourceID($ResourceID);
$Reservation->setStartDate($StartDate);
$Reservation->setEndDate($EndDate);
$Reservation->setUserID($UserID);

if (ReservationManagement::addReservation($Reservation))
    echo "Added...<br/>";
else
    echo "Not Added...<br/>";

$StartDate = '2010-05-03';
$EndDate = '2010-05-09';
$UserID = 18;
$ResourceID = 2;
$ReOccurrenceID = 1;
$StopDate = '2010-08-01';

echo "Add a new Record With the ReOccurrence_id and Stop_Date set<br/>";

$Reservation->setResourceID($ResourceID);
$Reservation->setStartDate($StartDate);
$Reservation->setEndDate($EndDate);
$Reservation->setUserID($UserID);
$Reservation->setReOccurrenceID($ReOccurrenceID);
$Reservation->setStopDate($StopDate);


if (ReservationManagement::addReservation($Reservation))
    echo "Added...<br/>";
else
    echo "Not Added...<br/>";


echo "Update a Record.... <br/>";
$ReservationID = 41;
$StartDate = '2010-4-4';
$EndDate = '2010-4-14';
$UserID = 23;
$ResourceID = 2;

$Reservation->setReservationID($ReservationID);
$Reservation->setResourceID($ResourceID);
$Reservation->setStartDate($StartDate);
$Reservation->setEndDate($EndDate);
$Reservation->setUserID($UserID);

ReservationManagement::updateReservation($Reservation);
echo "Updated...<br/>";

echo "get Record 43<br/>";
$ReservationID = 43;
$Reservation->setReservationID($ReservationID);
$Reservation = ReservationManagement::getReservationByID($Reservation);

if ($Reservation == false )
    echo "No record to display...<br/>";
else
    {
    echo $Reservation->getStartDate();
    echo "\t";
    echo $Reservation->getEndDate();
    echo "\t";
    echo $Reservation->getUserID();
    echo "<br/>";
    }

echo "get Records 45<br/>";
$ReservationID = 45;

$Reservation->setReservationID($ReservationID);
$Reservation = ReservationManagement::getReservationByID($Reservation);
if ($Reservation == false )
    echo "No record to display...<br/>";
else
    {
    echo $Reservation->getStartDate();
    echo "\t";
    echo $Reservation->getEndDate();
    echo "\t";
    echo $Reservation->getUserID();
    echo "<br/>";
    }

echo "Remove Record 58<br/>";
$ReservationID = 58;

$Reservation->setReservationID($ReservationID);
if (ReservationManagement::removeReservation($Reservation))
echo "Record 58 Removed <br/>";
else
echo "Record 58 NOT Removed <br/>";


echo "display all reservations... <br/>";
$UserID = 22;
$Reservation->setUserID($UserID);
$Array = ReservationManagement::getAllReservation($Reservation);

echo "Array count " . count($Array)."<br/>";

for ($i = 0; $i < count($Array); $i++ )
{
   echo $Array[$i]->getReservationID()."   ";
   echo $Array[$i]->getStartDate()."   ";
   echo $Array[$i]->getUserID()."   ";
   echo $Array[$i]->getEndDate()."<br/>";

}
echo "The End...";


?>
